/**
 * Created by 尼恩 at 疯狂创客圈
 */

package com.cheng.im.client.protoBuilder;


import com.cheng.im.client.session.ClientSession;
import com.cheng.im.common.bean.UserDTO;
import com.cheng.im.common.bean.msg.ProtoMsgV1;

/**
 * 登陆消息Builder
 */
public class LoginMsgBuilder extends BaseBuilder
{
    private final UserDTO user;

    public LoginMsgBuilder(UserDTO user, ClientSession session)
    {
        super(ProtoMsgV1.HeadType.LOGIN_REQUEST, session);
        this.user = user;
    }
    public ProtoMsgV1.Message build()
    {
        ProtoMsgV1.Message message = buildCommon(-1);
        ProtoMsgV1.LoginRequest.Builder lb =
                ProtoMsgV1.LoginRequest.newBuilder()
                        .setDeviceId(user.getDevId())
                        .setPlatformType(ProtoMsgV1.PlatformType.ANDROID)
                        .setToken(user.getToken())
                        .setUid(user.getUserId());
        return message.toBuilder().setLoginRequest(lb).build();
    }

    public static ProtoMsgV1.Message buildLoginMsg(
            UserDTO user, ClientSession session)
    {
        LoginMsgBuilder builder =
                new LoginMsgBuilder(user, session);
        return builder.build();

    }
}


